package com.playball.lottery.customview;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import com.playball.lottery.R;
import com.playball.lottery.frm.buyhall.CQSSCListActivity;
import com.playball.lottery.frm.buyhall.DltxhlbActivity;
import com.playball.lottery.frm.buyhall.ElvSelFiveListActivity;
import com.playball.lottery.frm.buyhall.ElvYunDJListActivity;
import com.playball.lottery.frm.buyhall.Fc3dListActivity;
import com.playball.lottery.frm.buyhall.Kuai3ListActivity;
import com.playball.lottery.frm.buyhall.N7lxhlbActivity;
import com.playball.lottery.frm.buyhall.N7xxhlbActivity;
import com.playball.lottery.frm.buyhall.Pailie3ListActivity;
import com.playball.lottery.frm.buyhall.Pailie5ListActivity;
import com.playball.lottery.frm.buyhall.SsqxhlbActivity;

/**
 * 
 * 新版购彩选号列表listview UI界面，包含  玩法和 注数 金额
 *
 */
public class NewDelButtonAdapter extends BaseAdapter {

	private class MyViewHolder {
		TextView Ball_red;
		TextView Ball_blue;
		TextView Ball_money;
		ImageButton buttonClose;
		TextView playtype;
	}

	private class MyElvSelFive {
		TextView ball;
		TextView ball_money;
		ImageButton buttonClose;
		TextView playtype;
	}

	private class MyJcFoot {
		TextView hteam;
		TextView vteam;
		Button sbut;
		Button pbut;
		Button fbut;
		Button buttonClose;
	}

	private ArrayList<HashMap<String, Object>> mAppList;
	private LayoutInflater mInflater;
	private Context mContext;
	private String[] keyString;
	private int[] valueViewID;
	private MyViewHolder myholder;
	private MyElvSelFive myElv;
	private MyJcFoot myFoot;

	private String str_hteam;
	private String str_vteam;
	private String str_sp;

	public NewDelButtonAdapter(ArrayList<HashMap<String, Object>> appList) {
		mAppList = appList;
	}

	public NewDelButtonAdapter(Context c, ArrayList<HashMap<String, Object>> appList, int resource, String[] from, int[] to) {
		mAppList = appList;
		mContext = c;
		mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		keyString = new String[from.length];
		valueViewID = new int[to.length];
		System.arraycopy(from, 0, keyString, 0, from.length);
		System.arraycopy(to, 0, valueViewID, 0, to.length);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// 双色球
		if (mContext.getClass().equals(SsqxhlbActivity.class)) {
			if (convertView != null) {
				myholder = (MyViewHolder) convertView.getTag();
			} else {
				convertView = mInflater.inflate(R.layout.buy_ssqxhlb_newlist, null);
				myholder = new MyViewHolder();
				myholder.Ball_red = (TextView) convertView.findViewById(valueViewID[0]);
				myholder.Ball_blue = (TextView) convertView.findViewById(valueViewID[1]);
				myholder.Ball_money = (TextView) convertView.findViewById(valueViewID[2]);
				myholder.buttonClose = (ImageButton) convertView.findViewById(valueViewID[3]);
				myholder.playtype = (TextView) convertView.findViewById(valueViewID[4]);
				convertView.setTag(myholder);
			}

			HashMap<String, Object> appInfo = mAppList.get(position);
			if (appInfo != null) {
				String ball1 = (String) appInfo.get(keyString[0]);
				String ball2 = (String) appInfo.get(keyString[1]);
				String money = (String) appInfo.get(keyString[2]);//ball3
				int bid = (Integer) appInfo.get(keyString[3]);
				String playtype = (String) appInfo.get(keyString[4]);
//				myholder.Ball_red.setText(ball1);
				myholder.Ball_red.setText(Html.fromHtml(ball1+"<font  color='#50a6ea'>" +"\t\t"+ ball2 + "</font>"));
//				myholder.Ball_blue.setText(ball2);
//				myholder.Ball_money.setText(ball3);
				myholder.Ball_money.setText((Integer.parseInt(money)/2)+"注\t\t"+money+"彩豆");
				// myholder.buttonClose.setImageDrawable(myholder.buttonClose.getResources().getDrawable(bid));
				myholder.buttonClose.setOnClickListener(new lvButtonListener(position, myholder.buttonClose.getId()));
				myholder.playtype.setText(playtype);
			}
		}else if(mContext.getClass().equals(DltxhlbActivity.class)){// 大乐透
			if (convertView != null) {
			myholder = (MyViewHolder) convertView.getTag();
		} else {
			convertView = mInflater.inflate(R.layout.buy_ssqxhlb_newlist, null);//buy_dltxhlb_list
			myholder = new MyViewHolder();
			myholder.Ball_red = (TextView) convertView.findViewById(valueViewID[0]);
			myholder.Ball_blue = (TextView) convertView.findViewById(valueViewID[1]);
			myholder.Ball_money = (TextView) convertView.findViewById(valueViewID[2]);
			myholder.buttonClose = (ImageButton) convertView.findViewById(valueViewID[3]);
			myholder.playtype = (TextView) convertView.findViewById(valueViewID[4]);
			convertView.setTag(myholder);
		}

		HashMap<String, Object> appInfo = mAppList.get(position);
//		Log.v("NewDelButtonAdapter", "getview mAppList= "+mAppList.toString());
		if (appInfo != null) {
			String ball1 = (String) appInfo.get(keyString[0]);
			String ball2 = (String) appInfo.get(keyString[1]);
//			String ball3 = (String) appInfo.get(keyString[2]);
			String money = (String) appInfo.get(keyString[2]);//ball3
			int bid = (Integer) appInfo.get(keyString[3]);
			String playtype = (String) appInfo.get(keyString[4]);
			int i5 = (Integer) appInfo.get(keyString[5]);
			int i6 = (Integer) appInfo.get(keyString[6]);
//			Log.v("NewDelButtonAdapter", "getview bid= "+bid);
//			Log.v("NewDelButtonAdapter", "getview i5= "+i5);//注数
//			Log.v("NewDelButtonAdapter", "getview i6= "+i6);//单注金额
			
//			myholder.Ball_red.setText(ball1);
//			myholder.Ball_blue.setText(ball2);
			myholder.Ball_red.setText(Html.fromHtml(ball1+"<font color='#50a6ea'>" +"\t\t"+ ball2 + "</font>"));
//			myholder.Ball_money.setText(ball3);
			myholder.Ball_money.setText(i5+"注\t\t"+i5*i6+"彩豆");
			// myholder.buttonClose.setImageDrawable(myholder.buttonClose.getResources().getDrawable(bid));
			myholder.buttonClose.setOnClickListener(new lvButtonListener(position, myholder.buttonClose.getId()));
			myholder.playtype.setText(playtype);
		}
		}
		 else if (mContext.getClass().equals(ElvSelFiveListActivity.class) || mContext.getClass().equals(ElvYunDJListActivity.class)|| mContext.getClass().equals(CQSSCListActivity.class)|| mContext.getClass().equals(Pailie3ListActivity.class) || mContext.getClass().equals(Pailie5ListActivity.class)
		|| mContext.getClass().equals(Kuai3ListActivity.class)|| mContext.getClass().equals(Fc3dListActivity.class)|| mContext.getClass().equals(N7lxhlbActivity.class)|| mContext.getClass().equals(N7xxhlbActivity.class)) {
	if (convertView != null) {
		myElv = (MyElvSelFive) convertView.getTag();
	} else {
		convertView = mInflater.inflate(R.layout.buy_new11x5_listnum, null);
		myElv = new MyElvSelFive();
		myElv.ball = (TextView) convertView.findViewById(valueViewID[0]);
		myElv.ball_money = (TextView) convertView.findViewById(valueViewID[1]);
		myElv.buttonClose = (ImageButton) convertView.findViewById(valueViewID[2]);
		myElv.playtype = (TextView) convertView.findViewById(valueViewID[3]);
		convertView.setTag(myElv);
	}

	HashMap<String, Object> appInfo = mAppList.get(position);
	if (appInfo != null) {
		String ball = (String) appInfo.get(keyString[0]);
		String money = (String) appInfo.get(keyString[1]);
		int bid = (Integer) appInfo.get(keyString[2]);
		String playtype = (String) appInfo.get(keyString[3]);
		myElv.ball.setText(ball);
		myElv.ball_money.setText((Integer.parseInt(money)/2)+"注"+money+"彩豆");
		// myElv.buttonClose.setBackgroundDrawable(myElv.buttonClose.getResources().getDrawable(bid));
		myElv.buttonClose.setOnClickListener(new lvButtonListener(position, myElv.buttonClose.getId()));
		myElv.playtype.setText("["+playtype+"]");
	}
} 

//			// 11选5  11运夺金 排列3 排列5 福彩3D 22选5
//		 else if (mContext.getClass().equals(ElvSelFiveListActivity.class) || mContext.getClass().equals(ElvYunDJListActivity.class)|| mContext.getClass().equals(CQSSCListActivity.class)
//				|| mContext.getClass().equals(Pailie3ListActivity.class) || mContext.getClass().equals(Pailie5ListActivity.class)
//				|| mContext.getClass().equals(Fc3dListActivity.class) || mContext.getClass().equals(N7xxhlbActivity.class)
//				|| mContext.getClass().equals(N7lxhlbActivity.class)|| mContext.getClass().equals(Kuai3ListActivity.class)) {
//			if (convertView != null) {
//				myElv = (MyElvSelFive) convertView.getTag();
//			} else {
//				convertView = mInflater.inflate(R.layout.buy_new11x5_listnum, null);
//				myElv = new MyElvSelFive();
//				myElv.ball = (TextView) convertView.findViewById(valueViewID[0]);
//				myElv.ball_money = (TextView) convertView.findViewById(valueViewID[1]);
//				myElv.buttonClose = (Button) convertView.findViewById(valueViewID[2]);
//				myElv.playtype = (TextView) convertView.findViewById(valueViewID[3]);
//				convertView.setTag(myElv);
//			}
//
//			HashMap<String, Object> appInfo = mAppList.get(position);
//			if (appInfo != null) {
//				String ball = (String) appInfo.get(keyString[0]);
//				String money = (String) appInfo.get(keyString[1]);
//				int bid = (Integer) appInfo.get(keyString[2]);
//				String playtype = (String) appInfo.get(keyString[3]);
//				myElv.ball.setText(ball);
//				myElv.ball_money.setText((Integer.parseInt(money)/2)+"注"+money+"彩豆");
//				// myElv.buttonClose.setBackgroundDrawable(myElv.buttonClose.getResources().getDrawable(bid));
//				myElv.buttonClose.setOnClickListener(new lvButtonListener(position, myElv.buttonClose.getId()));
//				myElv.playtype.setText("["+playtype+"]");
//			}
//			// 竞彩足球
//		} else if (mContext.getClass().equals(JcfootxhlbActivity.class)) {
//			if (convertView != null) {
//				myFoot = (MyJcFoot) convertView.getTag();
//			} else {
//				convertView = mInflater.inflate(R.layout.buy_jcxhlb_list, null);
//				myFoot = new MyJcFoot();
//				myFoot.hteam = (TextView) convertView.findViewById(valueViewID[0]);
//				myFoot.vteam = (TextView) convertView.findViewById(valueViewID[1]);
//				myFoot.sbut = (Button) convertView.findViewById(valueViewID[2]);
//				myFoot.pbut = (Button) convertView.findViewById(valueViewID[3]);
//				myFoot.fbut = (Button) convertView.findViewById(valueViewID[4]);
//				myFoot.buttonClose = (Button) convertView.findViewById(valueViewID[5]);
//				convertView.setTag(myFoot);
//			}
//
//			try {
//				myFoot.sbut.setSelected(false);
//				myFoot.pbut.setSelected(false);
//				myFoot.fbut.setSelected(false);
//				HashMap<String, Object> appInfo = mAppList.get(position);
//				if (appInfo != null) {
//					str_hteam = (String) appInfo.get(keyString[1]);
//					str_vteam = (String) appInfo.get(keyString[2]);
//					str_sp = (String) appInfo.get(keyString[3]);
//					int bid = (Integer) appInfo.get(keyString[4]);
//					myFoot.hteam.setText(str_hteam);
//					myFoot.vteam.setText(str_vteam);
////					System.out.println(str_hteam + "VS" + str_vteam + "----" + str_sp);
//					str_sp=JCUtil.zhuanHuanSPGeShi(str_sp);
//					if (containsAny(str_sp, "3")) {
//						myFoot.sbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "1")) {
//						myFoot.pbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "0")) {
//						myFoot.fbut.setSelected(true);
//					}
//					// myFoot.buttonClose.setBackgroundDrawable(myFoot.buttonClose.getResources().getDrawable(bid));
//					myFoot.buttonClose.setOnClickListener(new jcButtonListener(position, myFoot.buttonClose.getId()));
//				}
//			} catch (Exception e) {
//				// TODO: handle exception
//				System.out.println(e.toString());
//			}
//		} else if (mContext.getClass().equals(bdxhlbActivity.class)) {
//			if (convertView != null) {
//				myFoot = (MyJcFoot) convertView.getTag();
//			} else {
//				convertView = mInflater.inflate(R.layout.buy_jcxhlb_list, null);
//				myFoot = new MyJcFoot();
//				myFoot.hteam = (TextView) convertView.findViewById(valueViewID[0]);
//				myFoot.vteam = (TextView) convertView.findViewById(valueViewID[1]);
//				myFoot.sbut = (Button) convertView.findViewById(valueViewID[2]);
//				myFoot.pbut = (Button) convertView.findViewById(valueViewID[3]);
//				myFoot.fbut = (Button) convertView.findViewById(valueViewID[4]);
//				myFoot.buttonClose = (Button) convertView.findViewById(valueViewID[5]);
//				convertView.setTag(myFoot);
//			}
//
//			try {
//				myFoot.sbut.setSelected(false);
//				myFoot.pbut.setSelected(false);
//				myFoot.fbut.setSelected(false);
//				HashMap<String, Object> appInfo = mAppList.get(position);
//				if (appInfo != null) {
//					str_hteam = (String) appInfo.get(keyString[1]);
//					str_vteam = (String) appInfo.get(keyString[2]);
//					str_sp = (String) appInfo.get(keyString[3]);
//					int bid = (Integer) appInfo.get(keyString[4]);
//					myFoot.hteam.setText(str_hteam);
//					myFoot.vteam.setText(str_vteam);
////					System.out.println(str_hteam + "VS" + str_vteam + "----" + str_sp);
//					str_sp=JCUtil.zhuanHuanSPGeShi(str_sp);
//					if (containsAny(str_sp, "3")) {
//						myFoot.sbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "1")) {
//						myFoot.pbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "0")) {
//						myFoot.fbut.setSelected(true);
//					}
//					// myFoot.buttonClose.setBackgroundDrawable(myFoot.buttonClose.getResources().getDrawable(bid));
//					myFoot.buttonClose.setOnClickListener(new jcButtonListener(position, myFoot.buttonClose.getId()));
//				}
//			} catch (Exception e) {
//				// TODO: handle exception
//				System.out.println(e.toString());
//			}
//		} else if (mContext.getClass().equals(JcBasketballxhlbActivity.class)) {
//			if (convertView != null) {
//				myFoot = (MyJcFoot) convertView.getTag();
//			} else {
//				convertView = mInflater.inflate(R.layout.buy_jcbbxh_lb_list, null);
//				myFoot = new MyJcFoot();
//				myFoot.hteam = (TextView) convertView.findViewById(valueViewID[0]);
//				myFoot.vteam = (TextView) convertView.findViewById(valueViewID[1]);
//				myFoot.sbut = (Button) convertView.findViewById(valueViewID[2]);
//				myFoot.pbut = (Button) convertView.findViewById(valueViewID[3]);
//				myFoot.pbut.setVisibility(View.INVISIBLE);
//				myFoot.fbut = (Button) convertView.findViewById(valueViewID[4]);
//				myFoot.buttonClose = (Button) convertView.findViewById(valueViewID[5]);
//				convertView.setTag(myFoot);
//			}
//
//			try {
//				myFoot.sbut.setSelected(false);
//				myFoot.pbut.setSelected(false);
//				myFoot.fbut.setSelected(false);
//				HashMap<String, Object> appInfo = mAppList.get(position);
//				if (appInfo != null) {
//					str_hteam = (String) appInfo.get(keyString[1]);
//					str_vteam = (String) appInfo.get(keyString[2]);
//					str_sp = (String) appInfo.get(keyString[3]);
//					int bid = (Integer) appInfo.get(keyString[4]);
//					String strLQWF = (String) appInfo.get(keyString[5]);
//					myFoot.hteam.setText(str_hteam);
//					myFoot.vteam.setText(str_vteam);
////					System.out.println(str_hteam + "VS" + str_vteam + "----" + str_sp);
//
//					if (strLQWF.equals("RFSF")) {
//						myFoot.sbut.setText("主负");
//						myFoot.fbut.setText("主胜");
//					} else if (strLQWF.equals("SF")) {
//						myFoot.sbut.setText("主负");
//						myFoot.fbut.setText("主胜");
//					} else if (strLQWF.equals("DXF")) {
//						myFoot.sbut.setText("大分");
//						myFoot.fbut.setText("小分");
//					}
//					str_sp=JCUtil.zhuanHuanSPGeShi(str_sp);
//					if (containsAny(str_sp, "3")) {
//						myFoot.fbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "1")) {
//						myFoot.pbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "0")) {
//						myFoot.sbut.setSelected(true);
//					}
//					// myFoot.buttonClose.setBackgroundDrawable(myFoot.buttonClose.getResources().getDrawable(bid));
//					myFoot.buttonClose.setOnClickListener(new jcButtonListener(position, myFoot.buttonClose.getId()));
//				}
//			} catch (Exception e) {
//				// TODO: handle exception
//				System.out.println(e.toString());
//			}
//			// 胜负彩
//		} else if (mContext.getClass().equals(ZqsfcxhlbActivity.class)) {
//			if (convertView != null) {
//				myFoot = (MyJcFoot) convertView.getTag();
//			} else {
//				convertView = mInflater.inflate(R.layout.buy_jcxhlb_list, null);
//				myFoot = new MyJcFoot();
//				myFoot.hteam = (TextView) convertView.findViewById(valueViewID[0]);
//				myFoot.vteam = (TextView) convertView.findViewById(valueViewID[1]);
//				myFoot.sbut = (Button) convertView.findViewById(valueViewID[2]);
//				myFoot.pbut = (Button) convertView.findViewById(valueViewID[3]);
//				myFoot.fbut = (Button) convertView.findViewById(valueViewID[4]);
//				myFoot.buttonClose = (Button) convertView.findViewById(valueViewID[5]);
//				myFoot.buttonClose.setVisibility(View.INVISIBLE);
//				convertView.setTag(myFoot);
//			}
//
//			try {
//				myFoot.sbut.setSelected(false);
//				myFoot.pbut.setSelected(false);
//				myFoot.fbut.setSelected(false);
//				HashMap<String, Object> appInfo = mAppList.get(position);
//				if (appInfo != null) {
//					str_hteam = (String) appInfo.get(keyString[1]);
//					str_vteam = (String) appInfo.get(keyString[2]);
//					str_sp = (String) appInfo.get(keyString[3]);
//					int bid = (Integer) appInfo.get(keyString[4]);
//					myFoot.hteam.setText(str_hteam);
//					myFoot.vteam.setText(str_vteam);
////					System.out.println(str_hteam + "VS" + str_vteam + "----" + str_sp);
//					if (containsAny(str_sp, "3")) {
//						myFoot.sbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "1")) {
//						myFoot.pbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "0")) {
//						myFoot.fbut.setSelected(true);
//					}
//					// myFoot.buttonClose.setBackgroundDrawable(myFoot.buttonClose.getResources().getDrawable(bid));
//					// myFoot.buttonClose.setOnClickListener(new
//					// jcButtonListener(position, myFoot.buttonClose.getId()));
//				}
//			} catch (Exception e) {
//				// TODO: handle exception
//				System.out.println(e.toString());
//			}
//		} else if (mContext.getClass().equals(Zqrx9xhlbActivity.class)) {
//
//			if (convertView != null) {
//				myFoot = (MyJcFoot) convertView.getTag();
//			} else {
//				convertView = mInflater.inflate(R.layout.buy_jcxhlb_list, null);
//				myFoot = new MyJcFoot();
//				myFoot.hteam = (TextView) convertView.findViewById(valueViewID[0]);
//				myFoot.vteam = (TextView) convertView.findViewById(valueViewID[1]);
//				myFoot.sbut = (Button) convertView.findViewById(valueViewID[2]);
//				myFoot.pbut = (Button) convertView.findViewById(valueViewID[3]);
//				myFoot.fbut = (Button) convertView.findViewById(valueViewID[4]);
//				myFoot.buttonClose = (Button) convertView.findViewById(valueViewID[5]);
//				myFoot.buttonClose.setVisibility(View.INVISIBLE);
//				convertView.setTag(myFoot);
//			}
//
//			try {
//				myFoot.sbut.setSelected(false);
//				myFoot.pbut.setSelected(false);
//				myFoot.fbut.setSelected(false);
//				HashMap<String, Object> appInfo = mAppList.get(position);
//				if (appInfo != null) {
//					str_hteam = (String) appInfo.get(keyString[1]);
//					str_vteam = (String) appInfo.get(keyString[2]);
//					str_sp = (String) appInfo.get(keyString[3]);
//					int bid = (Integer) appInfo.get(keyString[4]);
//					myFoot.hteam.setText(str_hteam);
//					myFoot.vteam.setText(str_vteam);
////					System.out.println(str_hteam + "VS" + str_vteam + "----" + str_sp);
//					if (containsAny(str_sp, "3")) {
//						myFoot.sbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "1")) {
//						myFoot.pbut.setSelected(true);
//					}
//					if (containsAny(str_sp, "0")) {
//						myFoot.fbut.setSelected(true);
//					}
//					// myFoot.buttonClose.setBackgroundDrawable(myFoot.buttonClose.getResources().getDrawable(bid));
//					// myFoot.buttonClose.setOnClickListener(new
//					// jcButtonListener(position, myFoot.buttonClose.getId()));
//				}
//			} catch (Exception e) {
//				// TODO: handle exception
//				System.out.println(e.toString());
//			}
//
//		}
		return convertView;
	}

	class lvButtonListener implements OnClickListener {
		private int position;
		private int btnId;

		lvButtonListener(int pos, int id) {
			position = pos;
			btnId = id;
		}

		@Override
		@SuppressWarnings("all")
		public void onClick(View v) {
			int vid = v.getId();
			if (vid == btnId) {
				removeItem(position);
				if (mContext.getClass().equals(SsqxhlbActivity.class)) {
					((SsqxhlbActivity) mContext).InitBaseAdapter(mAppList);
				}
				if (mContext.getClass().equals(DltxhlbActivity.class)) {
					((DltxhlbActivity) mContext).InitBaseAdapter(mAppList);
				}
				if (mContext.getClass().equals(ElvSelFiveListActivity.class)) {
					((ElvSelFiveListActivity) mContext).initSimpleAdapter(mAppList);
				}
				if (mContext.getClass().equals(Kuai3ListActivity.class)) {
					((Kuai3ListActivity) mContext).initSimpleAdapter(mAppList);
				}
				if (mContext.getClass().equals(ElvYunDJListActivity.class)) {
					((ElvYunDJListActivity) mContext).initSimpleAdapter(mAppList);
				}
				if (mContext.getClass().equals(CQSSCListActivity.class)) {
					((CQSSCListActivity) mContext).initSimpleAdapter(mAppList);
				}
				if (mContext.getClass().equals(Pailie3ListActivity.class)) {
					((Pailie3ListActivity) mContext).initSimpleAdapter(mAppList);
				}
				if (mContext.getClass().equals(Pailie5ListActivity.class)) {
					((Pailie5ListActivity) mContext).initSimpleAdapter(mAppList);
				}
				if (mContext.getClass().equals(Fc3dListActivity.class)) {
					((Fc3dListActivity) mContext).initSimpleAdapter(mAppList);
				}
				if (mContext.getClass().equals(N7xxhlbActivity.class)) {
					((N7xxhlbActivity) mContext).initSimpleAdapter(mAppList);
				}
				if (mContext.getClass().equals(N7lxhlbActivity.class)) {
					((N7lxhlbActivity) mContext).initSimpleAdapter(mAppList);
				}
			}
		}
	}

	class jcButtonListener implements OnClickListener {
		private int position;
		private int btnId;

		jcButtonListener(int pos, int id) {
			position = pos;
			btnId = id;
		}

		@Override
		@SuppressWarnings("all")
		public void onClick(View v) {
			int vid = v.getId();
			if (vid == btnId) {
				if (mAppList.size() > 2) {
					removeItem(position);
//					if (mContext.getClass().equals(JcfootxhlbActivity.class)) {
//						((JcfootxhlbActivity) mContext).initBaseAdapter(mAppList);
//					} else if (mContext.getClass().equals(bdxhlbActivity.class)) {
//						((bdxhlbActivity) mContext).initBaseAdapter(mAppList);
//					} else if (mContext.getClass().equals(JcBasketballxhlbActivity.class)) {
//						((JcBasketballxhlbActivity) mContext).initBaseAdapter(mAppList);
//					}
				} else {
					Toast.makeText(mContext, R.string.select_at_least_two_game, Toast.LENGTH_SHORT).show();
				}
			}
		}
	}

	@Override
	public int getCount() {
		return mAppList.size();
	}

	@Override
	public Object getItem(int position) {
		return mAppList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public void removeItem(int position) {
//		if (mContext.getClass().equals(JcfootxhlbActivity.class)) {
////			((JcfootxhlbActivity) mContext).initBaseAdapter(mAppList);
//			JcfootxhlbActivity.initMoney();
//		} else if (mContext.getClass().equals(bdxhlbActivity.class)) {
////			((bdxhlbActivity) mContext).initBaseAdapter(mAppList);
//			bdxhlbActivity.initMoney();
//		} else if (mContext.getClass().equals(JcBasketballxhlbActivity.class)) {
////			((JcBasketballxhlbActivity) mContext).initBaseAdapter(mAppList);
//			JcBasketballxhlbActivity.initMoney();
//		}
		//如果用户点击删除操作非常快,可能会有数组下标越界异常
//		Log.v("removeItem", "position= "+position);
//		Log.v("removeItem", "mAppList.size()= "+mAppList.size());
		if(position>=mAppList.size()){
			return;
		}
		mAppList.remove(position);
		this.notifyDataSetChanged();
	}

	public ArrayList<BallDTO> GetSsqList() {
		ArrayList<BallDTO> newlist = new ArrayList<BallDTO>();
		//
		for (int i = 0; i < mAppList.size(); i++) {
			String ball1 = (String) mAppList.get(i).get(keyString[0]);
			String ball2 = (String) mAppList.get(i).get(keyString[1]);
			String money = (String) mAppList.get(i).get(keyString[2]);
			BallDTO ballDTO = new BallDTO();
			ballDTO.setSsq_ball(ball1 + "-" + ball2 + "-" + money);
			newlist.add(ballDTO);
		}
		return newlist;
	}

	public ArrayList<BallDTO> GetDltList() {
		ArrayList<BallDTO> newlist = new ArrayList<BallDTO>();
//		Log.d("NewDelButtonAdapter", "GetDltList  mAppList="+mAppList.toString());
		//
		for (int i = 0; i < mAppList.size(); i++) {
			String ball1 = (String) mAppList.get(i).get(keyString[0]);
			String ball2 = (String) mAppList.get(i).get(keyString[1]);
			String money = (String) mAppList.get(i).get(keyString[2]);
			Integer i3 = (Integer) mAppList.get(i).get(keyString[3]);//keyString[3]=buy_dltxhlb_list_dlt_delete
			String s4 = (String) mAppList.get(i).get(keyString[4]);//keyString[4]=buy_ssqxhlb_list_ssq_playtype
			Integer i5 = (Integer) mAppList.get(i).get(keyString[5]);//keyString[5]=buy_dltxhlb_list_dlt_zhushu
			Integer i6 = (Integer) mAppList.get(i).get(keyString[6]);
			
//			Log.d("NewDelButtonAdapter", "GetDltList  keyString[1]="+keyString[1]);
//			Log.d("NewDelButtonAdapter", "GetDltList  keyString[2]="+keyString[2]);
//			Log.d("NewDelButtonAdapter", "GetDltList  keyString[3]="+keyString[3]);
//			Log.d("NewDelButtonAdapter", "GetDltList  keyString[4]="+keyString[4]);
//			Log.d("NewDelButtonAdapter", "GetDltList  keyString[5]="+keyString[5]);
//			Log.d("NewDelButtonAdapter", "GetDltList  keyString[6]="+keyString[6]);
//			//
//			
//			Log.d("NewDelButtonAdapter", "GetDltList  s4="+s4);
//			Log.d("NewDelButtonAdapter", "GetDltList  i5="+i5);
//			Log.d("NewDelButtonAdapter", "GetDltList  i6="+i6);
			BallDTO ballDTO = new BallDTO();
//			ballDTO.setDlt_ball(ball1 + "-" + ball2 + "-" + money);
			ballDTO.setDlt_ball(ball1 + "-" + ball2 + "-" + money+ "-"+ i5 + "-"+i6);
			newlist.add(ballDTO);
		}
		return newlist;
	}

	public ArrayList<BallDTO> GetElvList() {
		ArrayList<BallDTO> newlist = new ArrayList<BallDTO>();
		//
		for (int i = 0; i < mAppList.size(); i++) {
			String ball = (String) mAppList.get(i).get(keyString[0]);
			String money = (String) mAppList.get(i).get(keyString[1]);
			BallDTO ballDTO = new BallDTO();
			ballDTO.setElv_ball(ball + "-" + money);
			newlist.add(ballDTO);
		}
		return newlist;
	}

	public ArrayList<BallDTO> GetPl3List() {
		ArrayList<BallDTO> newlist = new ArrayList<BallDTO>();
		//
		for (int i = 0; i < mAppList.size(); i++) {
			String ball = (String) mAppList.get(i).get(keyString[0]);
			String money = (String) mAppList.get(i).get(keyString[1]);
			BallDTO ballDTO = new BallDTO();
			ballDTO.setPl3_ball(ball + "-" + money);
			newlist.add(ballDTO);
		}
		return newlist;
	}

	public ArrayList<BallDTO> GetPl5List() {
		ArrayList<BallDTO> newlist = new ArrayList<BallDTO>();
		//
		for (int i = 0; i < mAppList.size(); i++) {
			String ball = (String) mAppList.get(i).get(keyString[0]);
			String money = (String) mAppList.get(i).get(keyString[1]);
			BallDTO ballDTO = new BallDTO();
			ballDTO.setPl5_ball(ball + "-" + money);
			newlist.add(ballDTO);
		}
		return newlist;
	}
	
	public ArrayList<ChildDTO> GetFootList() {
		ArrayList<ChildDTO> newlist = new ArrayList<ChildDTO>();
		//
		for (int i = 0; i < mAppList.size(); i++) {
			String mId = (String) mAppList.get(i).get(keyString[0]);
			String str_hteam = (String) mAppList.get(i).get(keyString[1]);
			String str_vteam = (String) mAppList.get(i).get(keyString[2]);
			String str_sp = (String) mAppList.get(i).get(keyString[3]);
			String str_time = (String) mAppList.get(i).get("tip_time");
//			 Log.v("DAda GetFootList", "mId= " + mId + " str_team= " +
//			 str_team + " str_sp= " + str_sp + " str_time= " + str_time);
			ChildDTO childdto = new ChildDTO();
			childdto.mId = mId;
//			childdto.str_team = str_team;
			childdto.hTeam = str_hteam;
			childdto.vTeam = str_vteam;
			childdto.str_sp = str_sp;
			childdto.eTime = str_time;
			newlist.add(childdto);
		}
//		for (ChildDTO child : newlist) {
//		    String jc_mid = child.getmId();
////		    String str_team = child.str_team;
//		    String str_hteam = child.gethTeam();
//		    String str_vteam = child.getvTeam();
//		    String str_sp = child.getStr_sp();
//		    Log.i("DelButtonAdapter", "GetFootList jc_mid="+jc_mid);
////		    Log.i("DelButtonAdapter", "GetFootList str_team="+str_team);
//		    Log.i("DelButtonAdapter", "GetFootList str_hteam="+str_hteam);
//		    Log.i("DelButtonAdapter", "GetFootList str_vteam="+str_vteam);
//		    Log.i("DelButtonAdapter", "GetFootList str_sp="+str_sp);
//		}
		return newlist;
	}

	// 判断字符串是否有特点的字符
	static boolean containsAny(String str, String searchChars) {
		return str.contains(searchChars);
	}
}